<?php
/**
 * Created by PhpStorm
 * User: whh
 * Date: 2022/7/28
 * Time: 16:02
 */

namespace app\common\model;
use app\backstage\model\ManagerUser;
use think\Model;

class Recommend extends Model
{
    use Common;

    protected $table = 'quick_recommend';


    public static function defaultTemplate()
    {
        $wu = [
            [
                'title' => '热门搜索',
                'freq' => 0,
            ]
        ];
        $man = [
            [
                'title' => '排行榜',
                'freq' => 1,
            ],
            [
                'title' => '全网热追',
                'freq' => 1,
            ],
            [
                'title' => '大神力作',
                'freq' => 1,
            ],
            [
                'title' => '火热新书',
                'freq' => 1,
            ],
            [
                'title' => '优质佳作',
                'freq' => 1,
            ]
        ];
        $woman = [
            [
                'title' => '排行榜',
                'freq' => 2,
            ],
            [
                'title' => '女生必看',
                'freq' => 2,
            ],
            [
                'title' => '最新上架',
                'freq' => 2,
            ],
            [
                'title' => '新品佳作',
                'freq' => 2,
            ],
            [
                'title' => '独家新书',
                'freq' => 2,
            ]
        ];
        return array_merge($wu, $man, $woman);
    }

    public function managerUser()
    {
        return $this->hasOne(ManagerUser::class, 'id', 'agent_id')->field("id,account");
    }

    public function novels()
    {
        return $this->hasMany(RecommendNovel::class, 'rid');
    }
}